package gameComponents;

import java.util.ArrayList;
import java.util.Random;

public class Fila {
	
	private int nFila;
	private int ancho;
	private ArrayList<Celda> celdas = new ArrayList<Celda>();
	
	public int getAncho() {
		return ancho;
	}

	public void setAncho(int ancho) {
		this.ancho = ancho;
	}

	public int getnFila() {
		return nFila;
	}

	public void setnFila(int nFila) {
		this.nFila = nFila;
	}

	public ArrayList<Celda> getCeldas() {
		return celdas;
	}

	public void setCeldas(ArrayList<Celda> celdas) {
		this.celdas = celdas;
	}
	
	public void cambiarNumeroFila(int fila){
		for(Celda celda : this.getCeldas()){
			celda.setY(fila);
		}
	}
	
	public Fila(int nFila,int ancho){
		
		this.setnFila(nFila);
		this.setAncho(ancho);
		for(int i = 0; i<this.getAncho(); i++){
			this.getCeldas().add(new Celda(i,nFila));
		}
		
	}

	public Celda buscarCeldaRandom() {
		
		Random random = new Random();
		int r  = random.nextInt(this.getAncho()-1);
		if(r == 0){
			return this.buscarCeldaRandom();
		}
		else{
			return this.getCeldas().get(r);
		}
	}
	
	
	
	

}
